<template>
  <div>
    <h2>添加</h2>
    <table class="table table-bordered">
      <tbody>
        <tr>
          <td>名称</td>
          <td>
            <input type="text" v-model="form.name" />
          </td>
        </tr>
        <tr>
          <td>密码</td>
          <td>
            <input type="password" v-model="form.pwd" />
          </td>
        </tr>
        <tr>
          <td>科室类别</td>
          <td>
            <select v-model="form.keshi">
              <option value="">请选择</option>
              <option>内科</option>
              <option>外科</option>
              <option>骨科</option>
              <option>儿童科</option>
            </select>
          </td>
        </tr>
        <tr>
          <td>创建时间</td>
          <td>
            <input type="date" v-model="form.ketime" />
          </td>
        </tr>
        <tr>
          <td>人数</td>
          <td>
            <input type="text" v-model="form.renshu" />
          </td>
        </tr>
        <tr>
          <td>介绍</td>
          <td>
            <textarea v-model="form.introduce"> </textarea>
          </td>
        </tr>
        <tr>
          <td></td>
          <td>
            <button @click="Add">添加</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { onMounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";
import "bootstrap/dist/css/bootstrap.min.css";
const router = useRouter();
const form: any = reactive({
  id: 0,
  name: "",
  pwd: "",
  keshi: "",
  ketime: "",
  renshu: "",
  introduce: "",
  isdelete: true,
});
const Add=()=>{
    if(!form.name){
        alert("名称不能为空");
        return;
    }
    if(form.name.length>=20){
        alert("名称不能超过二十个字符");
        return;
    }

    axios.post("https://localhost:7015/api/yiliaokeshi/Addkeshi",form).then(res=>{
        if(res.data>0){
            alert("添加成功");
        }
        else
        {
            alert("添加失败");
        }
    })
}
</script>

<style scoped></style>
